package org.feiye.studyday24;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class DateTest {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		System.out.println("输入年月日：");
		String date = in.nextLine();
		SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
		s.setLenient(false);// 禁用宽松格式
		try {
			Date d = s.parse(date);
			System.out.println(date);
			System.out.println(d);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

}
